<template>
  <div class="detain-goods-page">
    <div class="search-wrapper">
      <super-search :search-form="searchForm" :search-item-config="searchItemList" @search="searchHandle"></super-search>
    </div>
    <div class="content-wrapper">
      <a-tabs v-model:activeKey="activeKey" @change="changeTabHandle">
        <a-tab-pane key="1" :tab="`待申请(${pageStat['1']})`"></a-tab-pane>
        <a-tab-pane key="2" :tab="`申请中(${pageStat['2']})`"></a-tab-pane>
        <a-tab-pane key="3" :tab="`已驳回(${pageStat['3']})`"></a-tab-pane>
        <a-tab-pane key="4" :tab="`已放货(${pageStat['4']})`"></a-tab-pane>
        <a-tab-pane key="-1" :tab="`全部(${pageStat['-1']})`"></a-tab-pane>
      </a-tabs>
      <super-table
        :activeKey="activeKey"
        :height="tableHeight"
        ref="tableRef"
        v-model:page="searchForm.pageNum"
        v-model:limit="searchForm.pageSize"
        :loading="loading"
        :data="tableData"
        :total="searchForm.total"
        :column="tableColumn"
        @change-page="getData"
      >
        <template #tool>
          <a-button v-if="['1', '3'].includes(activeKey)" v-debounce type="primary" @click="applyReleaseCargoHandle">发起放货</a-button>
        </template>
        <template #releaseReason="{ row }">
          {{ getLabelByDict("RELEASE_REASON", row.releaseReason) }}
        </template>
        <template #releaseStatus="{ row }">
          <a-tag v-if="row.releaseStatus === 1" color="#009688"> 待申请 </a-tag>
          <a-tag v-if="row.releaseStatus === 2" color="#2db7f5"> 申请中 </a-tag>
          <a-tag v-if="row.releaseStatus === 3" color="#f50"> 已驳回 </a-tag>
          <a-tag v-if="row.releaseStatus === 4" color="#87d068"> 已放货 </a-tag>
        </template>
      </super-table>
    </div>
    <!-- 弹窗 -->
    <a-modal v-model:visible="dialogOpts.visible" :keyboard="false" :closable="false" :footer="null" :title="dialogOpts.title" :width="dialogOpts.width">
      <component v-model:visible="dialogOpts.visible" :is="dialogOpts.component" :type="dialogOpts.type" :pass-data="dialogOpts.passData" @submit="dialogSubmitHandle"></component>
    </a-modal>
  </div>
</template>
<script lang="ts">
import ApplyReleaseCargo from "./components/applyReleaseCargo/index.vue";
export default {
  name: "DetainGoods",
  components: {
    ApplyReleaseCargo
  }
};
</script>
<script lang="ts" setup>
import ModalHook from "@/hook/modalHook";
import TableHeightHook from "@/hook/tableHeightHook";
import InitHook from "./composables/initHook";
import OperationHook from "./composables/operationHook";
import CommonHook from "@/hook/commonHook";
import { searchItemList } from "./data";
const { tableHeight, loading } = TableHeightHook(110);
const { getLabelByDict } = CommonHook();
const { tableData, tableRef, activeKey, dialogOpts, drawerOpts, pageStat, searchForm, tableColumn } = InitHook();
const { searchHandle, getData, changeTabHandle, applyReleaseCargoHandle, pageStateic } = OperationHook({
  tableData,
  tableRef,
  activeKey,
  drawerOpts,
  dialogOpts,
  pageStat,
  loading,
  searchForm
});
const { dialogSubmitHandle } = ModalHook({
  drawerOpts,
  dialogOpts,
  callBack: () => {
    getData();
    pageStateic();
  }
});
searchHandle();
</script>
<style lang="stylus" scoped>
.detain-goods-page{
    height: 100%;
}
</style>
